//
//  MainViewController.swift
//  sinofert_Swift
//
//  Created by enway-wk on 2017/6/23.
//  Copyright © 2017年 enway-wk. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        addChildViewController(HomeViewController(), title: "首页", imageName: "foot_menu_home")
        addChildViewController(KnowViewController(), title: "知道", imageName: "foot_menu_know")
        addChildViewController(SoloveViewController(), title: "解决方案", imageName: "foot_menu_solove")
        addChildViewController(ShopingViewController(), title: "商城", imageName: "foot_menu_shop")
        addChildViewController(MeViewController(), title: "我的", imageName: "foot_menu_me")
    }
    
    //swift支持方法的重载
    fileprivate func addChildViewController(_ childVC: UIViewController,title:String,imageName:String) {
        
        //设置子控制器的属性
        childVC.title = title
        childVC.tabBarItem.image = UIImage(named: imageName)
        childVC.tabBarItem.selectedImage = UIImage(named: imageName+"_sel")
        
        //包装导航栏控制器
        let childNav = UINavigationController(rootViewController:childVC)
        
        //添加控制器
        addChildViewController(childNav)
    }

}
